<?php


namespace app\validate\user;


use think\Validate;

class SubCompanyValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'require|integer',
        'company_name' => 'require',
        'company_type' => 'require',
        'business_img' => 'require',
        'authorization' => 'require',

        'invoice_type' => 'require|in:1,2',
        'invoice_title' => 'require',
        'invoice_tax' => 'require',
        'reg_address' => 'requireIf:invoice_type,2',
        'reg_tel' => 'requireIf:invoice_type,2',
        'bank_name' => 'requireIf:invoice_type,2',
        'bank_account' => 'requireIf:invoice_type,2',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.integer' => 'ID类型错误',
        'company_name.require' => '企业名称不能为空',
        'company_type.require' => '企业类型不能为空',
        'business_img.require' => '请上传营业执照',
        'authorization.require' => '请上传授权书',
        'invoice_type.require' => '请选择发票类型',
        'invoice_type.in' => '发票类型错误',
        'invoice_title.require' => '抬头名称不能为空',
        'invoice_tax.require' => '单位税号不能为空',
        'reg_address.requireIf' => '注册地址不能为空',
        'reg_tel.requireIf' => '注册电话不能为空',
        'bank_name.requireIf' => '开户银行不能为空',
        'bank_account.requireIf' => '银行账号不能为空',
    ];

    protected $scene = [
        'add' => ['company_name', 'company_type', 'business_img', 'authorization', 'invoice_type',
            'invoice_title', 'invoice_tax', 'reg_address', 'reg_tel', 'bank_name', 'bank_account'],
        'edit' => ['id', 'company_name', 'company_type', 'business_img', 'authorization', 'invoice_type',
            'invoice_title', 'invoice_tax', 'reg_address', 'reg_tel', 'bank_name', 'bank_account'],
    ];
}